package main

import (
	server "ServiceComputing/hw7-cloudgo/Server"
	"log"
	"net/http"
	"os"
)

const (
	PORT string = "8080"
)

func main() {
	port := os.Getenv("PORT")
	if len(port) == 0 {
		port = PORT
	}

	// default routing
	http.HandleFunc("/", server.Login)

	fs := http.FileServer(http.Dir("Assets"))
	http.Handle("/assets/", http.StripPrefix("/assets/", fs))

	// js access
	http.HandleFunc("/jsaccess", server.JSTest)

	// post access
	http.HandleFunc("/login", server.Login)

	// port
	err := http.ListenAndServe(":"+port, nil)
	if err != nil {
		log.Fatal("ListenAndServer: ", err)
	}
}
